package org.example.controller.shanjia;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.Dianpu;
import org.example.result.Result;
import org.example.service.DianpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/shanjia/dianpu")
@Slf4j
@Api(tags = "店铺相关接口")
public class GldianpuController {

    @Autowired
    DianpuService dianpuService;
    /**
     * 修改店铺

     * @param avatar
     * @param background
     * @return
     */
    @PostMapping("/xg")
    @ApiOperation(value = "店铺修改")
    public Result dianpuxg(@RequestPart("dianpu") Dianpu dianpu,
                           @RequestPart("avatar") MultipartFile avatar,
                           @RequestPart("background") MultipartFile background,
                           @RequestPart("username") String username) {
        log.info("店铺修改参数为：{}", dianpu);
        dianpuService.dianpuxg(dianpu.getShopName(),dianpu.getShopDescription(),avatar,background,username);
        return Result.success();
    }


    /**
     * 商品分类查询
     * @param
     * @return
     */
    @GetMapping ("/info")
    @ApiOperation(value = "商品修改")
    public Result<Dianpu> dianpucx(@RequestParam( "username")String username) {
        log.info("店铺查询：{}", username);

        return Result.success( dianpuService.dianpucx(username));
    }

}
